package com.googlecode.perfectable.visuable.webchat.ui;

import com.googlecode.perfectable.visuable.event.ButtonPushEvent;
import com.googlecode.perfectable.visuable.event.EventListener;
import com.googlecode.perfectable.visuable.visual.ValueHoldingVisual;
import com.googlecode.perfectable.webchat.ChatService;
import com.googlecode.perfectable.webchat.StandardMessage;

public class SendListener implements EventListener<ButtonPushEvent> {
	private ChatService chatService;
	private ValueHoldingVisual source;

	@Override
	public void receive(ButtonPushEvent event) {
		String body = this.source.value();
		this.chatService.receive(StandardMessage.of(body));
		this.source.setValue("");
	}

	public void setSource(ValueHoldingVisual source) {
		this.source = source;
	}

	public void setChatService(ChatService chatService) {
		this.chatService = chatService;
	}
}
